home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / magl / pixel.asm < prev    next >
Assembly Source File  |  1991-10-18  |  19KB  |  936 lines

  1. ;
  2. ;            'Magl.exp'     for FM-TOWNS
  3. ;
  4. ;        - MAKIchan Graphic loader is not 鮪だ! -
  5. ;
  6. ;            Version 0.30    Update 1991/04/09
  7. ;
  8. ;                programmed by MALOR
  9. ;
  10.  
  11.     .386p
  12.  
  13. HeaderSize    equ    32/4
  14. Plane2    equ    0104h
  15. Plane1    equ    010ch
  16.  
  17. CODE    segment dword public use32 'CODE'
  18.     assume cs:CODE,ds:DATA
  19.  
  20. ;int  inpb(int addr)
  21.  
  22.     public inpb
  23.     db    'inpb',4
  24. inpb    proc near
  25.     xor    eax,eax
  26.     mov    dx,[esp+4]
  27.     in    al,dx
  28.     ret
  29. inpb    endp
  30.  
  31. ;void outpb(int addr,int dat)
  32.  
  33.     public outpb
  34.     db    'outpb',5
  35. outpb    proc near
  36.     mov    dx,[esp+4]
  37.     mov    al,[esp+8]
  38.     out    dx,al
  39.     ret
  40. outpb    endp
  41.  
  42. ;****************************************
  43. ;     mag format pixel decode 
  44. ;****************************************
  45.  
  46. ;int    mag(char *maghead,int mode,int offset,int xpixel);
  47.  
  48. flgdec    macro    flg_bit                ;flag decode macro
  49.     local    Then
  50.     local    Endif
  51.  
  52.     rol    dl,1
  53.     jnc    short Then
  54.     lodsb                    ;read flag b to al
  55.                         ;flag b pointer(esi) incliment
  56.     jmp    short Endif
  57.     align    4
  58. Then:    xor    al,al                ;write 0 to flag
  59. Endif:    stosb                    ;write al to es:[edi]
  60.                         ;flag pointer(edi) incliment
  61.     endm
  62.  
  63.     public mag
  64.     db    'mag',3
  65.     align    4
  66. mag    proc    near
  67.  
  68.     pushad                    ;汎用レジスタ全部push
  69.  
  70.     mov    eax,ss:[esp+36+4]        ;mode
  71.     mov    ds:[Mode],eax
  72.     mov    eax,ss:[esp+36+8]        ;VRAMオフセット
  73.     mov    ds:[Vofs],eax
  74.     mov    eax,ss:[esp+36+12]        ;横方向のループ回数
  75.     mov    ds:[Xloopc],ax
  76.  
  77.     mov    esi,ss:[esp+36+0]        ;ヘッダをコピー
  78.  
  79.     cld                    ;メモリ転送はインクリメント方向
  80.  
  81.     push    es
  82.     mov    ax,ds                ;dsをesにコピー
  83.     mov    es,ax
  84.  
  85.     mov    edi,offset Header
  86.     mov    ecx,HeaderSize
  87.     rep movsd
  88.  
  89. ;flag a,b decode
  90.  
  91.     mov    ebp,ds:[flga]            ;*ebp=flga
  92.     mov    esi,ds:[flgb]            ;*esi=flgb
  93.     mov    edi,ds:[flg ]            ;*edi=flg
  94.  
  95.     movzx    edx,ds:[RY]            ;Y方向のループ回数セット
  96.     sub    dx,ds:[LY]
  97.     inc    edx
  98.     mov    ds:[YLoopc],dx            ;ワークにセット
  99.     movzx    eax,ds:[XLoopc]            ;X方向のループ回数セット
  100.     mul    edx                ;eax = eax * edx;edx broken
  101.     mov    ebx,eax
  102.     mov    ecx,eax                ;Loop counter (ecx) set
  103.     shr    ecx,3                ;ecx = ecx / 8
  104.  
  105.     align    4
  106.  
  107. LOOP2:    jz    short LOOP2_Exit
  108.     mov    dl,ds:[ebp]
  109.     flgdec                    ;展開じゃ展開じゃ!
  110.     flgdec
  111.     flgdec
  112.     flgdec
  113.     flgdec
  114.     flgdec
  115.     flgdec
  116.     flgdec
  117.     inc    ebp
  118.     dec    ecx
  119.     jmp    short LOOP2
  120.  
  121. LOOP2_Exit:
  122.  
  123.     mov    dl,ds:[ebp]
  124.     and    ebx,7h
  125.     jmp    ds:[ebx*4+Jtable2]
  126.  
  127.     align    4
  128.  
  129. jt27:    flgdec
  130. jt26:    flgdec
  131. jt25:    flgdec
  132. jt24:    flgdec
  133. jt23:    flgdec
  134. jt22:    flgdec
  135. jt21:    flgdec
  136. jt20:    
  137.  
  138. ; 1 line xor
  139.  
  140.     mov    esi,ds:[flg]            ;esi = 1ライン上のポインタ
  141.     mov    edi,esi                ;edi = フラグのポインタ
  142.     movzx    ecx,ds:[XLoopc]            ;ecx = *XLoopc
  143.     add    edi,ecx                ;edi = esi + *XLoopc
  144.     movzx    eax,ds:[RY]
  145.     sub    ax,ds:[LY]            ;eax = ry - ly
  146.     mul    ecx                ;eax *= ecx    ;edx broken
  147.     mov    ecx,eax                ;ecx = Loop counter
  148.     mov    ebx,eax
  149.     shr    ecx,2
  150.  
  151.     align    4
  152.  
  153. LOOP1:    jz    short LOOP1_Exit
  154.     lodsd
  155.     xor    ds:[edi],eax
  156.     add    edi,4
  157.     dec    ecx
  158.     jmp    short LOOP1
  159.  
  160. LOOP1_Exit:
  161.  
  162.     and    ebx,3
  163.     jmp    ds:[ebx*4+Jtable1]
  164.  
  165.     align    4
  166.  
  167. jt13:    lodsb
  168.     xor    ds:[edi],al
  169.     inc    edi
  170. jt12:    lodsb
  171.     xor    ds:[edi],al
  172.     inc    edi
  173. jt11:    lodsb
  174.     xor    ds:[edi],al
  175. jt10:
  176.  
  177.     mov    eax,ds:[Mode]
  178.     and    eax,20h
  179.     jz    Mem                ;仮想vramに展開
  180.  
  181.     movzx    ecx,ds:[LX]            ;左端のVRAMオフセット計算
  182.     mov    bl,ds:[Screen]
  183.     and    bl,80h
  184.     jnz    short ThenA
  185.     shr    ecx,3
  186.     shl    ecx,2                ;ecx = (ecx/8)*4
  187.     jmp    short EndifA
  188. ThenA:    shr    ecx,2
  189.     shl    ecx,2                ;ecx = (ecx/4)*4
  190. EndifA:    add    ds:[Vofs],ecx            ;水平方向誤差修正
  191.     mov    eax,ds:[Lineofs]
  192.     movzx    ecx,ds:[LY]
  193.     mul    ecx                ;eax = LY * Lineofs ;edx broken
  194.     add    ds:[Vofs],eax            ;垂直方向誤差修正
  195.     mov    edi,ds:[Vofs]            ;edi = VRAMのポインタ
  196.  
  197.     mov    ax,Plane1
  198.     mov    bl,ds:[Screen]
  199.     and    bl,80h
  200.     jnz    Mode8                ;256色展開
  201.  
  202.     mov    ax,Plane2
  203.     jmp    short Mode4            ;DOS互換モード
  204.  
  205. Mem:    mov    edi,ds:[vram]
  206.     mov    ds:[Vofs],edi
  207.     mov    ax,ds
  208.     mov    bl,ds:[Screen]
  209.     and    bl,80h
  210.     jnz    Mode8
  211.  
  212. ;pixel decode (16色モード)
  213.  
  214. Mode4:    mov    es,ax                ;VRAMセレクタセット
  215.  
  216.     xor    ebx,ebx                ;関係レジスタ初期化
  217.     xor    edx,edx
  218.     xor    ecx,ecx
  219.  
  220.                         ;edi = VRAM/RAMへのポインタ
  221.     mov    esi,ds:[flg]            ;esi = フラグのポインタ
  222.     mov    ebp,ds:[pix]            ;ebp = ピクセルのポインタ
  223.  
  224.     mov    dx,ds:[YLoopc]            ;Y方向のループ回数セット
  225.  
  226.     align    4
  227.  
  228. LOOPY2:    mov    cx,ds:[XLoopc]            ;cx set
  229.  
  230.     ;左ピクセル展開
  231.  
  232.     align    4
  233.  
  234. LOOPX2:    xor    ebx,ebx
  235.     mov    bl,ds:[esi]            ;flag read
  236.     jmp    ds:[ebx*4+Jtable3]
  237.  
  238. LOOPX2_Exit:
  239.  
  240.     mov    edi,ds:[Vofs]            ;ediに1ライン分のオフセット加算
  241.     add    edi,ds:[Lineofs]
  242.     mov    ds:[Vofs],edi
  243.  
  244.     dec    dx
  245.     jnz    short LOOPY2
  246.     jmp    Exit
  247.  
  248.     ;特化ピクセル展開ルーチン群
  249.     ; flag = 00h
  250.     align    4
  251. jtp0:    mov    eax,ds:[ebp]            ;pixel read to ax
  252.     add    ebp,4                ;pixel incliment
  253.     ror    al,4                ;上位下位4ビット交換
  254.     ror    ah,4
  255.     ror    eax,16
  256.     ror    al,4                ;上位下位4ビット交換
  257.     ror    ah,4
  258.     ror    eax,16
  259.     stosd
  260.     inc    esi                ;Flag incliment
  261.     dec    ecx
  262.     jnz    LOOPX2
  263.     jmp    LOOPX2_Exit
  264.  
  265.     ; flag = 0?h
  266.     align    4
  267. jtp1:    and    bl,0fh
  268.     mov    ebx,ds:[ebx*4+Mofs]        ;前方参照
  269.     mov    ax,es:[edi+ebx+2]        ;VRAM read to ax
  270.     shl    eax,16
  271.     mov    ax,ds:[ebp]            ;pixel read to ax
  272.     add    ebp,2
  273.     ror    al,4                ;上位下位4ビット交換
  274.     ror    ah,4
  275.     stosd
  276.     inc    esi                ;flag incliment
  277.     dec    ecx
  278.     jnz    LOOPX2
  279.     jmp    LOOPX2_Exit
  280.  
  281.     ; flag = ?0h
  282.     align    4
  283. jtp2:    mov    ax,ds:[ebp]            ;pixel read to ax
  284.     add    ebp,2                ;pixel incliment
  285.     ror    al,4                ;上位下位4ビット交換
  286.     ror    ah,4
  287.     shl    eax,16
  288.     shr    bl,4
  289.     mov    ebx,ds:[ebx*4+Mofs]        ;前方参照
  290.     mov    ax,es:[edi+ebx]            ;VRAM read to ax
  291.     stosd
  292.     inc    esi                ;flag incliment
  293.     dec    ecx
  294.     jnz    LOOPX2
  295.     jmp    LOOPX2_Exit
  296.  
  297.     ; flag = ??h
  298.     align    4
  299. jtp3:    and    ebx,0fh
  300.     mov    ebx,ds:[ebx*4+Mofs]        ;前方参照
  301.     mov    ax,es:[edi+ebx+2]        ;VRAM read to ax
  302.     shl    eax,16
  303.     xor    ebx,ebx
  304.     mov    bl,ds:[esi]            ;flag read
  305.     shr    bl,4
  306.     mov    ebx,ds:[ebx*4+Mofs]        ;前方参照
  307.     mov    ax,es:[edi+ebx]            ;VRAM read to ax
  308.     stosd
  309.     inc    esi                ;Flag incliment
  310.     dec    ecx
  311.     jnz    LOOPX2
  312.     jmp    LOOPX2_Exit
  313.  
  314.     ; flag = 01h
  315.     align    4
  316. jtp4:    mov    ax,ds:[ebp]            ;pixel read to ax
  317.     add    ebp,2                ;pixel incliment
  318.     ror    al,4                ;上位下位4ビット交換
  319.     ror    ah,4
  320.     mov    bx,ax
  321.     shl    eax,16
  322.     or    eax,ebx
  323.     stosd
  324.     inc    esi                ;Flag incliment
  325.     dec    ecx
  326.     jnz    LOOPX2
  327.     jmp    LOOPX2_Exit
  328.  
  329.     ; flag = ?1h
  330.     ; or same two pixels read
  331.     align    4
  332. jtp5:    shr    bl,4
  333.     mov    ebx,ds:[ebx*4+Mofs]        ;前方参照
  334.     mov    ax,es:[edi+ebx]            ;VRAM read to ax
  335.     xor    ebx,ebx
  336.     mov    bx,ax
  337.     shl    eax,16
  338.     or    eax,ebx
  339.     stosd
  340.     inc    esi                ;Flag incliment
  341.     dec    ecx
  342.     jnz    LOOPX2
  343.     jmp    LOOPX2_Exit
  344.  
  345.     ; flag = 10h
  346.     align    4
  347. jtp6:    mov    ax,ds:[ebp]            ;pixel read to ax
  348.     add    ebp,2                ;pixel incliment
  349.     ror    al,4                ;上位下位4ビット交換
  350.     ror    ah,4
  351.     ror    eax,16
  352.     stosd
  353.     inc    esi                ;Flag incliment
  354.     dec    ecx
  355.     jnz    LOOPX2
  356.     jmp    LOOPX2_Exit
  357.  
  358.     ; flag = 1?h
  359.     align    4
  360. jtp7:    and    bl,0fh
  361.     mov    ebx,ds:[ebx*4+Mofs]        ;前方参照
  362.     mov    ax,es:[edi+ebx+2]        ;VRAM read to ax
  363.     ror    eax,16
  364.     stosd
  365.     inc    esi                ;Flag incliment
  366.     dec    ecx
  367.     jnz    LOOPX2
  368.     jmp    LOOPX2_Exit
  369.  
  370.     ; flag = 22h
  371.     align    4
  372. jtp8:    stosd
  373.     inc    esi                ;Flag incliment
  374.     dec    ecx
  375.     jnz    LOOPX2
  376.     jmp    LOOPX2_Exit
  377.  
  378.     ; flag = 33h 44h .... eeh ffh
  379.     align    4
  380. jtps:    shr    bl,4
  381.     mov    ebx,ds:[ebx*4+Mofs]        ;前方参照
  382.     mov    eax,es:[edi+ebx]        ;VRAM read to ax
  383.     stosd
  384.     inc    esi                ;Flag incliment
  385.     dec    ecx
  386.     jnz    LOOPX2
  387.     jmp    LOOPX2_Exit
  388.  
  389.     ; flag = 11h,12h
  390.     align    4
  391. jtpe:    mov    ebx,eax                ; eax = pre pixel data
  392.     shr    ebx,16
  393.     xor    ax,ax
  394.     or    eax,ebx
  395. temp:    stosd
  396.     inc    esi                ;Flag incliment
  397.     dec    ecx
  398.     jz    LOOPX2_Exit
  399.     mov    bl,ds:[esi]
  400.     cmp    bl,11h                ;名付けて11hアクセレーター!
  401.     je    short temp
  402.     or    ecx,ecx
  403.     jnz    LOOPX2
  404.     jmp    LOOPX2_Exit
  405.  
  406. ;pixel decode (256色モード)
  407.  
  408. Mode8:    mov    es,ax                ;VRAMセレクタセット
  409.  
  410.     xor    eax,eax                ;関係レジスタ初期化
  411.     xor    ebx,ebx
  412.     xor    edx,edx
  413.     xor    ecx,ecx
  414.  
  415.     mov    ebp,ds:[flg]            ;ebp = フラグのポインタ
  416.     mov    esi,ds:[pix]            ;esi = ピクセルのポインタ
  417.  
  418.     mov    dx,ds:[YLoopc]            ;Y方向のループ回数セット
  419.                         ;Y loop counter=dx
  420.     test    dx,0ffffh
  421.  
  422.     align    4
  423.  
  424. LOOPY3:    jz    Exit
  425.     mov    cx,ds:[XLoopc]            ;cx set
  426.     test    cx,0ffffh
  427.  
  428.     ;左ピクセル展開
  429.  
  430.     align    4
  431.  
  432. LOOPX3:    jz    short LOOPX3_Exit
  433.     mov    al,ds:[ebp]            ;flag read
  434.     shr    al,4
  435.     jz    short Then5
  436.     mov    ebx,ds:[eax*4+Mofs]        ;前方参照
  437.     mov    ax,es:[edi+ebx]            ;VRAM read to ax
  438.     jmp    short Endif5
  439.  
  440.     align    4
  441.  
  442. Then5:    lodsw                    ;pixel read to ax
  443.                         ;pixel pointer(esi) incliment
  444. Endif5:    stosw                        ;VRAM write from ax
  445.                         ;VRAM pointer(edi) incliment
  446.     xor    eax,eax
  447.  
  448.     ;右ピクセル展開
  449.  
  450.     mov    al,ds:[ebp]            ;flag read
  451.     and    al,0fh
  452.     jz    short Then6
  453.     mov    ebx,ds:[eax*4+Mofs]        ;前方参照
  454.     mov    ax,es:[edi+ebx]            ;VRAM read to ax
  455.     jmp    short Endif6
  456.  
  457.     align    4
  458.  
  459. Then6:    lodsw                    ;pixel read to ax
  460.                         ;pixel pointer(esi) incliment
  461. Endif6:    stosw                    ;VRAM write from ax
  462.                         ;VRAM pointer(edi) incliment
  463.     xor    eax,eax
  464.  
  465.     inc    ebp                ;Flag incliment
  466.     dec    ecx
  467.     jmp    short LOOPX3
  468. ;    loop    LOOPX3
  469.  
  470. LOOPX3_Exit:
  471.  
  472.     mov    edi,ds:[Vofs]            ;ediに1ライン分のオフセット加算
  473.     add    edi,ds:[Lineofs]
  474.     mov    ds:[Vofs],edi
  475.     dec    dx
  476.     jmp    LOOPY3
  477.  
  478. Exit:    pop    es
  479.  
  480.     popad                    ;汎用レジスタ全部pop
  481.  
  482.     ret
  483.  
  484. mag    endp
  485.  
  486. ;****************************************
  487. ;     maki format pixel decode 
  488. ;****************************************
  489.  
  490. mkiflg    macro
  491.     local    Endif1
  492.     local    Endif2
  493.  
  494.     rol    dl,1                ;Carry Flagに抽出
  495.     jnc    short Endif1            ;CF == 0 : jmp Endif
  496.     lodsw                    ;Read from flag b to ax
  497.                         ;flag b pointer(esi)incliment
  498.     mov    bx,ax
  499.     and    ax,0f0f0h
  500.     shl    bx,4
  501.     and    bx,0f0f0h
  502.     mov    ds:[edi],al            ;write to Flag
  503.     mov    ds:[edi+40],bl
  504.     mov    ds:[edi+80],ah
  505.     mov    ds:[edi+120],bh
  506. Endif1:    rol    dl,1
  507.     jnc    short Endif2
  508.     lodsw
  509.     mov    bx,ax
  510.     shr    ax,4
  511.     and    ax,0f0fh
  512.     and    bx,0f0fh
  513.     or    ds:[edi],al
  514.     or    ds:[edi+40],bl
  515.     or    ds:[edi+80],ah
  516.     or    ds:[edi+120],bh
  517. Endif2:    inc    edi
  518.     endm
  519.  
  520. mkipix    macro
  521.     local    Then
  522.     local    Endif
  523.  
  524.     rol    dl,1                ;Carry flagに抽出
  525.     jc    short Then            ;CF == 1 : jmp Then
  526.     xor    al,al                ;write 0 to pix
  527.     jmp    short Endif
  528.  
  529.     align    4
  530.  
  531. Then:    lodsb                    ;read from pix to al
  532.                         ;pix pointer(esi) incliment
  533.     ror    al,4                ;上位下位交換
  534. Endif:    stosb                    ;write al to VRAM(es:[edi])
  535.     endm
  536.  
  537. ;int mki(char *mkihead,int mode,int offset);
  538.     public mki
  539.     db    'mki',3
  540.     align    4
  541. mki    proc near
  542.  
  543.     pushad
  544.  
  545.     mov    eax,ss:[esp+36+4]        ;mode
  546.     mov    ds:[Mode],eax
  547.     mov    eax,ss:[esp+36+8]        ;VRAMオフセット
  548.     mov    ds:[Vofs],eax
  549.     mov    eax,ss:[esp+36+0]        ;ヘッダ先頭アドレス
  550.     mov    ds:[SizA],eax            ;SizAが代わりのワーク
  551.  
  552.     cld                    ;flag clear
  553.     mov    ecx,4000
  554.     mov    edi,ds:[flg]
  555.     xor    eax,eax
  556.     rep stosd
  557.  
  558.     ;flag a,b decode
  559.  
  560.     mov    ecx,100                ;ecx = Y loop counter
  561.     mov    edi,ds:[flg]            ;edi = flag pointer
  562.     mov    esi,ds:[flgb]            ;esi = flag b pointer
  563.     mov    ebp,ds:[flga]            ;ebp = flag a pointer
  564.  
  565.     align    4
  566.  
  567. LOOPY5:    mov    dh,10                ;dh = X loop counter
  568.  
  569.     align    4
  570.  
  571. LOOPX5:    mov    dl,ds:[ebp]            ;dl = flag a
  572.     mkiflg
  573.     mkiflg
  574.     mkiflg
  575.     mkiflg
  576.     inc    ebp                ;flag a pointer(ebp) incliment
  577.     dec    dh                ;X loop counter decliment
  578.     jnz    LOOPX5
  579.     add    edi,40*3            ;1 line offset
  580.     dec    ecx                ;Y loop counter decliment
  581.     jnz    LOOPY5
  582.  
  583.     ;pixel decode
  584.  
  585.     mov    eax,ds:[Mode]
  586.     and    eax,20h
  587.     jz    Pix2M                ;メモリ展開モード
  588.     mov    ebx,ds:[Mode]
  589.     and    ebx,40h
  590.     jnz    Pix2V                ;DOS互換モード
  591.  
  592.     ;1024*512画面モード
  593.  
  594.     align    4
  595.  
  596. Pix1:    mov    ax,Plane2            ;VRAM selecter set to es
  597.     mov    es,ax
  598.     mov    edi,ds:[Vofs]            ;es:[edi] = VRAM pointer
  599.     mov    esi,ds:[pix]            ;esi = pix pointer
  600.     mov    ebp,ds:[flg]            ;ebp = Flag pointer
  601.     xor    eax,eax                ;eax clear
  602.     mov    ebx,400                ;Y loop counter = ebx
  603.  
  604.     align    4
  605.  
  606. LOOPY6:    mov    ecx,40
  607.  
  608.     align    4
  609.  
  610. LOOPX6:    mov    dl,ds:[ebp]
  611.     mkipix
  612.     mkipix
  613.     mkipix
  614.     mkipix
  615.     mkipix
  616.     mkipix
  617.     mkipix
  618.     mkipix
  619.     inc    ebp
  620.     dec    ecx
  621.     jnz    LOOPX6
  622.     add    edi,192
  623.     dec    ebx
  624.     jnz    LOOPY6
  625.  
  626.     mov    esi,ds:[Vofs]            ; 1 Line Xor
  627.     mov    edi,esi
  628.  
  629.     mov    eax,ds:[SizA]
  630.     mov    al,ds:[eax+6]
  631.     cmp    al,'A'
  632.     je    Then9
  633.     cmp    al,'B'
  634.     jne    Exit2
  635.  
  636.     add    edi,512*4            ; 4 Line 毎
  637.     mov    ebx,396
  638.     jmp    Endif9
  639. Then9:    add    edi,512*2            ; 2 Line 毎
  640.     mov    ebx,398
  641. Endif9:    
  642.  
  643.     align    4
  644.  
  645. LOOPY7:    mov    ecx,80
  646.  
  647.     align    4
  648.  
  649. LOOPX7:    mov    eax,es:[esi]
  650.     xor    es:[edi],eax
  651.     add    esi,4
  652.     add    edi,4
  653.     loop    LOOPX7
  654.     add    esi,192
  655.     add    edi,192
  656.     dec    ebx
  657.     jnz    LOOPY7
  658.  
  659.     jmp    Exit2
  660.  
  661.     ;DOS互換モード&仮想vram
  662.  
  663. Pix2M:    mov    ax,ds                ;Data selecter set to es
  664.     mov    edi,ds:[vram]            ;仮想vramアドレス
  665.     mov    ds:[Vofs],edi
  666.     jmp    short Pix2
  667. Pix2V:    mov    ax,Plane2            ;VRAM selecter set to es
  668.     xor    edi,edi                ;vramアドレス初期化
  669.     mov    ds:[Vofs],edi
  670. Pix2:    mov    es,ax
  671.     xor    eax,eax
  672.     mov    ecx,16000
  673.     mov    esi,ds:[pix]
  674.     mov    ebp,ds:[flg]
  675.  
  676.     align    4
  677.  
  678. LOOP8:    mov    dl,ds:[ebp]
  679.     mkipix
  680.     mkipix
  681.     mkipix
  682.     mkipix
  683.     mkipix
  684.     mkipix
  685.     mkipix
  686.     mkipix
  687.     inc    ebp
  688.     dec    ecx
  689.     jnz    LOOP8
  690.  
  691.     mov    edi,ds:[Vofs]
  692.     mov    esi,edi
  693.  
  694.     mov    eax,ds:[SizA]
  695.     mov    al,ds:[eax+6]
  696.     cmp    al,'A'
  697.     je    short Then10
  698.     cmp    al,'B'
  699.     jnz    Exit2
  700.  
  701.     add    edi,320*4            ; 4 Line 毎
  702.     mov    ecx,396*80
  703.     jmp    short Endif10
  704. Then10:    add    edi,320*2            ; 2 Line 毎
  705.     mov    ecx,398*80
  706. Endif10:
  707.  
  708.     align    4
  709.  
  710. LOOP9:    mov    eax,es:[esi]
  711.     xor    es:[edi],eax
  712.     add    esi,4
  713.     add    edi,4
  714.     loop    LOOP9
  715.  
  716. Exit2:    mov    ax,ds
  717.     mov    es,ax
  718.  
  719.     popad
  720.  
  721.     ret
  722.  
  723. mki    endp
  724.  
  725. ;************************************
  726. ;    Copy memory to VRAM
  727. ;************************************
  728.  
  729. ;int move(int xbyte,int ylooptime,int sofs,int slineofs,int seg,int dofs,int dlineofs);
  730.  
  731.     public move
  732.     db    'move',4
  733.     align    4
  734. move    proc near
  735.  
  736.     pushad
  737.  
  738.     mov    ecx,ss:[esp+36+0]        ;x loop counter = ecx
  739.     mov    ds:[XLoopc],cx
  740.     mov    ebx,ss:[esp+36+4]        ;y loop counter = ebx
  741.     mov    eax,ss:[esp+36+8]        ;source オフセット
  742.     mov    ds:[Sofs],eax
  743.     mov    eax,ss:[esp+36+12]        ;source line オフセット
  744.     mov    ds:[Slofs],eax
  745.     mov    eax,ss:[esp+36+16]        ;dest. セレクタ
  746.     mov    es,ax
  747.     mov    eax,ss:[esp+36+20]        ;dest. オフセット
  748.     mov    ds:[Vofs],eax
  749.     mov    eax,ss:[esp+36+24]        ;dest. line オフセット
  750.     mov    ds:[Vlofs],eax
  751.  
  752.     xor    ecx,ecx
  753.  
  754.     mov    esi,ds:[Sofs]
  755.     mov    edi,ds:[Vofs]
  756.  
  757.     align    4
  758.  
  759. LOOP10:    mov    cx,ds:[XLoopc]
  760.     shr    cx,2
  761.     rep movsd
  762.     mov    cx,ds:[Xloopc]
  763.     and    cx,3
  764.     rep movsb
  765.  
  766.     mov    esi,ds:[Sofs]
  767.     add    esi,ds:[Slofs]
  768.     mov    ds:[Sofs],esi
  769.  
  770.     mov    edi,ds:[Vofs]
  771.     add    edi,ds:[Vlofs]
  772.     mov    ds:[Vofs],edi
  773.     
  774.     dec    ebx
  775.     jnz    short LOOP10
  776.     
  777.     mov    ax,ds
  778.     mov    es,ax
  779.  
  780.     popad
  781.  
  782.     ret
  783.     
  784. move    endp
  785.  
  786. CODE    ends
  787.  
  788. DATA    segment dword
  789.     assume ds:DATA
  790.  
  791.     align    4
  792.     ;前方参照オフセットアドレステーブル
  793. Mofs    dd    -(512*0+0),-(512*0+2),-(512*0+4),-(512*0+8)
  794.     dd    -(512*1+0),-(512*1+2)
  795.     dd    -(512*2+0),-(512*2+2),-(512*2+4)
  796.     dd    -(512*4+0),-(512*4+2),-(512*4+4)
  797.     dd    -(512*8+0),-(512*8+2),-(512*8+4)
  798.     dd    -(512*16+0)
  799.  
  800.     ;1ライン分のオフセット
  801. Lineofs    dd    512
  802.  
  803.     align    4
  804.  
  805. ; header
  806. Header    db    0    ;ヘッダの先頭
  807. Machine    db    0    ;機種コード
  808. Rflg    db    0    ;機種依存フラグ
  809. Screen    db    0    ;スクリーンモード
  810. LX    dw    0    ;表示開始位置X
  811. LY    dw    0    ;表示開始位置Y
  812. RX    dw    639    ;表示終了位置X
  813. RY    dw    399    ;表示終了位置Y
  814. OffA    dd    0    ;フラグAのオフセット
  815. OffB    dd    0    ;フラグBのオフセット
  816. SizB    dd    0    ;フラグBのサイズ
  817. OffP    dd    0    ;ピクセルのオフセット
  818. SizP    dd    0    ;ピクセルのサイズ
  819.  
  820. ;Other work
  821.  
  822. SizA    dd    0    ;フラグAのサイズ
  823.  
  824. ;Temporary work
  825.  
  826. XLoopc    dw    0    ;X方向のループ回数
  827. YLoopc    dw    0    ;Y方向のループ回数
  828. Vofs    dd    0    ;展開領域の左端のVRAMオフセット
  829. Mode    dd    4    ;画面モード == 4 : 16色1024*512モード
  830.             ;        == 8 : 256色1024*512モード
  831.             ;        == 1 : DOS互換640*400モード
  832. Sofs    dd    0    ;展開元領域の左端オフセット
  833. Slofs    dd    0    ;
  834. Vlofs    dd    0    ;
  835.  
  836. ;Table
  837.  
  838.     ;xorループの出口のジャンプテーブル
  839.  
  840. Jtable1    dd    offset jt10,offset jt11, offset jt12,offset jt13
  841.  
  842.     ;flag decode ループの出口のジャンプテーブル
  843. Jtable2    dd    offset jt20,offset jt21,offset jt22,offset jt23
  844.     dd    offset jt24,offset jt25,offset jt26,offset jt27
  845.  
  846.     ;pixcel decode (16色) の特化ジャンプテーブル
  847.     ;jtp0 : flag = 00h    ;jtp1 : flag = 0?h
  848.     ;jtp2 : flag = ?0h    ;jtp3 : flag = ??h
  849.     ;jtp4 : flag = 01h    ;jtp5 : flag = ?1h
  850.     ;jtp6 : flag = 10h    ;jtp7 : flag = 1?h
  851.     ;jtp8 : flag = 22h    ;;jtp9 : flag = 21h    ;;印は効果が期待でき
  852.     ;;jtpa : flag = 02h    ;;jtpb : flag = ?2h    ないので、未サポート
  853.     ;;jtpc : flag = 20h    ;;jtpd : flag = 2?h
  854.     ;jtpe : flag = 11h,12h
  855.     ; 連続ピクセルを参照
  856.     ;jtps : flag = 33h,・・・・・・,ffh
  857.     ; 2ピクセルが同一ピクセルを参照
  858.     ;jtp5 : flag = 45h,67h,78h,9ah,abh,cdh,deh
  859. Jtable3    dd    offset jtp0,offset jtp4,offset jtp1,offset jtp1    ; 00h ~ 0fh
  860.     dd    offset jtp1,offset jtp1,offset jtp1,offset jtp1
  861.     dd    offset jtp1,offset jtp1,offset jtp1,offset jtp1
  862.     dd    offset jtp1,offset jtp1,offset jtp1,offset jtp1
  863.     dd    offset jtp6,offset jtpe,offset jtpe,offset jtp7    ; 10h ~ 1fh
  864.     dd    offset jtp7,offset jtp7,offset jtp7,offset jtp7
  865.     dd    offset jtp7,offset jtp7,offset jtp7,offset jtp7
  866.     dd    offset jtp7,offset jtp7,offset jtp7,offset jtp7
  867.     dd    offset jtp2,offset jtp5,offset jtp8,offset jtp3    ; 20h ~ 2fh
  868.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  869.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  870.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  871.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtps    ; 30h ~ 3fh
  872.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  873.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  874.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  875.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; 40h ~ 4fh
  876.     dd    offset jtps,offset jtp5,offset jtp3,offset jtp3
  877.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  878.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  879.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; 50h ~ 5fh
  880.     dd    offset jtp3,offset jtps,offset jtp3,offset jtp3
  881.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  882.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  883.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; 60h ~ 6fh
  884.     dd    offset jtp3,offset jtp3,offset jtps,offset jtp5
  885.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  886.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  887.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; 70h ~ 7fh
  888.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtps
  889.     dd    offset jtp5,offset jtp3,offset jtp3,offset jtp3
  890.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  891.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; 80h ~ 8fh
  892.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  893.     dd    offset jtps,offset jtp3,offset jtp3,offset jtp3
  894.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  895.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; 90h ~ 9fh
  896.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  897.     dd    offset jtp3,offset jtps,offset jtp5,offset jtp3
  898.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  899.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; a0h ~ afh
  900.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  901.     dd    offset jtp3,offset jtp3,offset jtps,offset jtp5
  902.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  903.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; b0h ~ bfh
  904.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  905.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtps
  906.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  907.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; c0h ~ cfh
  908.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  909.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  910.     dd    offset jtps,offset jtp5,offset jtp3,offset jtp3
  911.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; d0h ~ dfh
  912.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  913.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  914.     dd    offset jtp3,offset jtps,offset jtp5,offset jtp3
  915.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; e0h ~ efh
  916.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  917.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  918.     dd    offset jtp3,offset jtp3,offset jtps,offset jtp3
  919.     dd    offset jtp2,offset jtp5,offset jtp3,offset jtp3    ; f0h ~ ffh
  920.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  921.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtp3
  922.     dd    offset jtp3,offset jtp3,offset jtp3,offset jtps
  923.  
  924. DATA    ends
  925.  
  926.     public Mofs
  927.     public Lineofs
  928.     extrn flga:dword
  929.     extrn flgb:dword
  930.     extrn flg:dword
  931.     extrn pix:dword
  932.     extrn vram:dword
  933.     extrn screen_mode:byte
  934.  
  935.     end
  936.